package com.wlc.base.lambda;

import java.util.function.Function;
import java.util.function.IntPredicate;

/**
 * @author 王立朝
 * @description lambda表达式
 * @date 2021-11-05 15:00:54
 */
public class TestLambda06 {

    public static void main(String[] args) {
        method01();
    }

    /**
     * 测试
     */
    public static void method01() {
//        printNum(new IntPredicate() {
//            @Override
//            public boolean test(int value) {
//                return false;
//            }
//        });
//        printNum((int value)-> false);
        printNum((int value) ->
                value % 2 == 0
        );

    }


    public static <R> R typeConver(Function<String, R> function) {
        String str = "12345";
        R result = function.apply(str);
        return result;

    }

    public static void printNum(IntPredicate intPredicate) {

        int[] arr = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9};
        for (int i = 0; i < arr.length; i++) {
            if (intPredicate.test(i)) {
                System.out.println(i);

            }
        }

    }

}
